<?php 
define('IN_WONDERSHARE', true);
header("Content-type:text/html;charset=utf-8");
require('../includes/init.php');
require('./classes/control/control_faq_index.php');
class Faq_Index
{
	var $faq_comment_c;
	var $webType;//网站类型
	/**
	* @ 构造函数,实例化CommentControl
	* @ __construct
	*/
	
	public function __construct()
	{
		$this->faq_index_c = new FaqIndexControl();
		$this->webType = empty($_REQUEST['web_type'])?1:(int)trim($_REQUEST['web_type']);
	}

	/**
	* 函数index,返回默认列表
	* @param  NULL
	* @return  string
	*/
	function index()
	{
		$index_info = array();
		$index_info = $this->faq_index_c->get_index_info('list',0,$this->webType);//得到首页推荐信息
		$GLOBALS['smarty']->assign('web_type',     $this->webType);
		$GLOBALS['smarty']->assign('index_info',$index_info );
		$GLOBALS['smarty']->display('faq_index_comment.htm'); 
	}

	/**
	* 函数index,返回默认列表
	* @param  NULL
	* @return  string
	*/
	
	public function edit()
	{	
		if($_REQUEST['act'] == 'edit' && !empty($_REQUEST['re_id']))
		{
			if($_POST['sub_from'])
			{
				//删除队列
				queueDelete(0, $_POST['re_id']);
				
				$edit_array = array
				(
				're_id' => trim($_POST['re_id']),
				're_category_id' => trim($_POST['h_category_str_id']),
				're_product_id' => trim($_POST['h_product_str_id'])
				);
			
				$affect = $this->faq_index_c->operate_comment('edit',$edit_array);
				if($affect == 1)
				{
					echo  '<script type="text/javascript"> alert("编辑成功！");
					window.location.href="/wondershare/faq_index.php?action=edit&act=edit&re_id='.$_REQUEST['re_id'].'&web_type='.$this->webType.'"; </script>';
				}else
				{
					echo  '<script type="text/javascript"> alert("编辑失败！");
					window.location.href="/wondershare/faq_index.php?action=edit&act=edit&re_id='.$_REQUEST['re_id'].'&web_type='.$this->webType.'"; </script>';
				}
			}else{
				//加入队列
				queueInfo($_GET['re_id']);
			}
			
			$index_info = $this->faq_index_c->get_index_info('edit',(int)$_GET['re_id'],$this->webType);
			$GLOBALS['smarty']->assign('web_type',     $this->webType);
			$GLOBALS['smarty']->assign('web_info',   get_web_info($this->webType));
			$GLOBALS['smarty']->assign('tile',     '修改');
			$GLOBALS['smarty']->assign('chr_13',     chr(13));
			$GLOBALS['smarty']->assign('form_act',     'edit');
			$GLOBALS['smarty']->assign('index_info',$index_info[0]);
			$GLOBALS['smarty']->display('faq_index_info.htm'); 	
		}
	}
	/**
	* 弹出框显示
	* @param  NULL
	* @return  string
	*/
	public function category_list()
	{
		$category__info = $this->faq_index_c->get_index_category();
		$category_listdata = !empty($_REQUEST['category_str_list'])?explode(',',$_REQUEST['category_str_list']):array();
		$GLOBALS['smarty']->assign('category_listdata',$category_listdata);
		$GLOBALS['smarty']->assign('category__info',$category__info);
		$GLOBALS['smarty']->display('faq_category_list.htm'); 
	}

}
$action    = $_REQUEST['action']; 
$faq_comment   = new Faq_Index;
if(method_exists($faq_comment, $action)) 
{
	$faq_comment->$action();
}else{
	$faq_comment->index();
}

?>
